<template>
	<view class="main">	
	    <!-- #ifdef MP-WEIXIN -->
	    <navbar :bgColor="bgColor" :btnColors='btnColor' title="绑定银行卡" :isGoBack="true" :isNotice="true" :visible="true" ></navbar>
		<!-- #endif -->		
		<view class="goods_list">
			<view class="flex flex-wrap">					
				<block  v-for="(item,index) in list" :key="key">
					<view class="classify-cell-recom  border-b" :style="{backgroundImage:'url(' + item.image + ')'}" style="height: 300rpx;" @click="()=>bank_info(item)">
						<view class="default_img" v-if="item.is_default==1" style="width: 104rpx;height: 42rpx;background: #FFFFFF;border-radius: 0rpx 0rpx 0rpx 16rpx;">
							  <view class="default_text pr-20 pt-5" style="font-size: 24rpx;">
								默认
							  </view>			   								
						</view>
						<view class=" ellipsis">
							 <image :src="item.logo" style="width: 40rpx;height: 40rpx;"></image>									
							 <text  class="ml-20">{{item.bank_name}}</text>
						</view>
						
						<view class="ellipsis bank_num">
							{{item.bank_num}}
						</view>
						
						<view class="flex justify-end mt-15 mr-20">
							  <view class="flex">
								  <view class="flex ml-20 mr-20 button-border align-center text-center justify-center" style="font-size: 28rpx; width: 154rpx;border: 1rpx solid #fff;color: #fff;" @click="()=>handleDel(item)">
																	
									<text  size="22">删除</text>								 	
								  </view>
								 <view class="flex button-border mr-20 align-center text-center justify-center bg-white" style="font-size: 28rpx;  border: 1rpx solid #fff;color: #36B3E9; width: 154rpx;" @click="()=>handleEdit(item)">
									<!-- <u-icon name="edit-pen" ></u-icon> -->
									<text  size="22">编辑</text>									
								 </view>
								
							  </view>							
						</view>	
					
					</view>
				</block>             
			</view> 
		</view> 	
			
		<view class="about-button" style="background-color: #ffffff">
			<view class="ml-15">						
				<button class="about-button-alipay" style="background:#36B3E9;border: none;color: #ffffff;height: 80rpx;text-align: center;line-height: 88rpx;height: 88rpx;;" @click="add_bank">
					<u-icon name="plus"  color="#fff"></u-icon>
					<view class=" ml-10">
						新增银行卡
					</view>
					</button>
			</view>			
		</view>
	</view>	
</template>

<script>
	export default {
		data () {
			return {
				...getApp().globalData.config,
				list:[],
				show: false,
				invite_number:'',
				dollId:'',
				router:'',
				options:'',
			}			
		},
		onShow() {
			this.query_list()
		},
		created() {
			let pages = getCurrentPages() // 获取栈实例
			let prevPage = pages[pages.length - 2] // 获取上个页面的数据，包含页面
			this.router=prevPage.route
			this.options=prevPage.options
			// this.recommendId=prevPage.recommendId
		},
		methods:{
			...getApp().globalData.function,	
			//添加银行卡
			add_bank(){
				this.$routers.router('/pages/pagesuser/bankList/setting','navigateTo') 
				
			},
			
			//银行卡信息
			bank_info(item){
				if(this.router=='pages/pagesuser/docash_draw/index'){
					this.$routers.router('/pages/pagesuser/docash_draw/index?bankId='+item.id,'navigateTo') 
				}
			},
			//获取信息
			query_list(){
				let obj={
					token:uni.getStorageSync('userInfo').token
				}
				this.$http.memberBankList(obj).then(res=>{		
					if(res.resCode=='9999'){
						this.list=res.data.bank_list
					}else{
						this.list=[]
					}
				})
			},	
			
			//编辑
			handleEdit(item){
				uni.navigateTo({
					url:"/pages/pagesuser/bankList/setting?item="+JSON.stringify(item)
				})
			},
			//删除银行卡
			handleDel(item){	
				console.log('item',item)
				let that=this			
				uni.showModal({content: '确定删除银行卡吗？'}).then(res=>{			
				  if(res.confirm){
					this.$http.delMemberBank({
						token:uni.getStorageSync('userInfo').token,
						bankId:item.id,
					}).then(res=>{
						if(res.resCode=='9999'){
						  uni.showToast({title:res.resMessage,icon:'none'})
						  setTimeout(()=>{
							  this.query_list();
						  },2000)          
						  return
						}else{
						  uni.showToast(res.resMessage)
						}
					})       
				  }
				})
			},
		},
		
	}
</script>

<style>
	@import "./index.css";
</style>